package cn.lccabc.array.no0167;

/**
 * @program: leet-code
 * @description:
 * @author: LiCC
 * @create: 2019-12-28 10:37
 */
public class Solution01 {
    public int[] twoSum(int[] numbers, int target) {
        int start = 0, end = numbers.length - 1;
        while (start < end){
            int sum = numbers[start] + numbers[end];
            if (sum == target){
                return new int[]{start, end};
            } else if (sum < target){
                start ++;
            } else {
                end --;
            }
        }
        return null;
    }

    public static void main(String[] args) {
        int[] nums = {2,7,11,15};
        int target = 9;
        Solution01 solution = new Solution01();
        int[] a = solution.twoSum(nums, target);
        System.out.println(a[0] + " - " +a[1]);
    }
}
